package oj;

/**
 * @author 郝文雪
 * @date 2022/8/17 19:27
 * @Description Test
 */
public class LC1706 {
    //简单模拟题
    public int[] findBall(int[][] grid) {
        int n=grid[0].length;
        int[] arr=new int[n];
        for(int j=0;j<n;j++){
            int col=j;
            for(int[] row:grid){
                int dir=row[col];
                col+=dir;
                if(col<0 || col==n || dir!=row[col]){
                    col=-1;
                    break;
                }
            }
            arr[j]=col;
        }
        return arr;
    }
}
